package com.dhcc.emergency4mayor;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Timer;
import java.util.TimerTask;

import com.dhcc.service.RoadNetWebService;
import com.dhcc.service.WebService;
import com.esri.android.map.MapView;
import com.esri.android.map.ags.ArcGISDynamicMapServiceLayer;
import com.esri.android.map.ags.ArcGISTiledMapServiceLayer;
import com.esri.android.map.event.OnStatusChangedListener;

import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.text.Html;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.Toast;

public class TrafficPicActivity extends Activity {

	boolean mapThread = false;
	//10.10.149.7:8887 WebService
	
	String address5="http://172.28.18.2:7777/phone/images/rs_init.png";
	String address3="http://172.28.18.2:7777/phone/images/rs_big.png";
	
	byte[] data,data2;
	TextView allnet,allnetdata,allnetstatus;
	TextView eastcity,eastcitydata,eastcitystatus;
	TextView westcity,westcitydata,westcitystatus;
	TextView haidiancity,haidiancity_data,haidiancity_status;
	TextView chaoyangcity,chaoyangcity_status,chaoyangcity_data;
	TextView fengtaicity,fengtaicity_data,fengtaicity_status;
	TextView shijingshancity,shijingshancity_data,shijingshancity_status;
	
	TextView circle2,circle2_data,circle2_status;
	TextView circle23,circle23_data,circle23_status;
	TextView circle34,circle34_data,circle34_status;
	TextView circle45,circle45_data,circle45_status;
	
	private Timer timer2 = new Timer();
	private Timer timer1 = new Timer();
	private Timer timer = new Timer();
	private TimerTask task,task1,task2;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_traffic_pic);
		ImageView dt5ImageView=(ImageView) findViewById(R.id.dt);
		dt5ImageView.setVisibility(View.VISIBLE);
		 ImageView rd5imageView = (ImageView) findViewById(R.id.MapPic);
		 rd5imageView.setVisibility(View.VISIBLE);
		 ImageView dt4ImageView=(ImageView) findViewById(R.id.dt2);
		 dt4ImageView.setVisibility(View.INVISIBLE);
		 ImageView rd4imageView = (ImageView) findViewById(R.id.MapPic2);
		 rd4imageView.setVisibility(View.INVISIBLE);
		 
		 allnet=(TextView) findViewById(R.id.allnet);
		 allnetdata=(TextView) findViewById(R.id.allnetdata);
		 allnetstatus=(TextView) findViewById(R.id.allnetstatus);
		 eastcity=(TextView) findViewById(R.id.eastcity);
		 eastcitydata=(TextView) findViewById(R.id.eastcity_data);
		 eastcitystatus=(TextView) findViewById(R.id.eastcity_status);
		 westcity=(TextView) findViewById(R.id.westcity);
		 westcitydata=(TextView) findViewById(R.id.westcity_data);
		 westcitystatus=(TextView) findViewById(R.id.westcity_status);
		 haidiancity=(TextView) findViewById(R.id.haidiancity);
		 haidiancity_data=(TextView) findViewById(R.id.haidiancity_data);
		 haidiancity_status=(TextView) findViewById(R.id.haidiancity_status);
		 chaoyangcity=(TextView) findViewById(R.id.chaoyangcity);
		 chaoyangcity_status=(TextView) findViewById(R.id.chaoyangcity_status);
		 chaoyangcity_data=(TextView) findViewById(R.id.chaoyangcity_data);
		 fengtaicity=(TextView) findViewById(R.id.fengtaicity);
		 fengtaicity_data=(TextView) findViewById(R.id.fengtaicity_data);
		 fengtaicity_status=(TextView) findViewById(R.id.fengtaicity_status);
		 shijingshancity=(TextView) findViewById(R.id.shijingshancity);
		 shijingshancity_data=(TextView) findViewById(R.id.shijingshancity_data);
		 shijingshancity_status=(TextView) findViewById(R.id.shijingshancity_status);
		 circle2=(TextView) findViewById(R.id.circle2);
		 circle2_data=(TextView) findViewById(R.id.circle2_data);
		 circle2_status=(TextView) findViewById(R.id.circle2_status);
		 circle23=(TextView) findViewById(R.id.circle23);
		 circle23_data=(TextView) findViewById(R.id.circle23_data);
		 circle23_status=(TextView) findViewById(R.id.circle23_status);
		 circle34=(TextView) findViewById(R.id.circle34);
		 circle34_data=(TextView) findViewById(R.id.circle34_data);
		 circle34_status=(TextView) findViewById(R.id.circle34_status);
		 circle45=(TextView) findViewById(R.id.circle45);
		 circle45_data=(TextView) findViewById(R.id.circle45_data);
		 circle45_status=(TextView) findViewById(R.id.circle45_status);
		 
		new Thread() {
			public void run() {
			
						ConnectivityManager cwjManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
						NetworkInfo info = cwjManager.getActiveNetworkInfo();
						if (info != null && info.isAvailable()) {// 判断当前设备是否可以联网
							if (isConnByHttp()) {
								task = new TimerTask() {

									@Override
									public void run() {
										// TODO Auto-generated method stub
										data = WebService.getImage(address5);
										Message message = new Message();
										message.what = 0;
										handler.sendMessage(message);
									}
								
								};
								timer.schedule(task, 500, 150000);
								
								task1 = new TimerTask() {

									@Override
									public void run() {
										// TODO Auto-generated method stub
										data2 = WebService.getImage(address3);
										Message message = new Message();
										message.what = 5;
										handler.sendMessage(message);
										
									}
								
								};
								timer1.schedule(task1, 500, 150000);
								
								task2 = new TimerTask() {

									@Override
									public void run() {
										// TODO Auto-generated method stub
										RoadString = RoadNetWebService
												.getRoadNetString("getTrafficIndex");
										//System.out.println("thread:"+RoadString);
										Message message = new Message();
										message.what = 1;
										handler.sendMessage(message);
									}
								
								};
								timer2.schedule(task2, 500, 150000);
								
								
								/*// 内网
								String ditu = "http://172.19.19.101:8399";
								// 外网
								//String ditu = "http://114.251.193.161:8399";
								//String ditu2="http://10.212.137.160:8399";//路况图修细版
								// 实时
								// String ditu="172.24.186.147:8399";
								tileLayers = new ArcGISTiledMapServiceLayer(ditu+ "/arcgis/rest/services/bjtest/MapServer");
								// 内网
								 trafficPic = new
								 ArcGISDynamicMapServiceLayer(ditu+"/arcgis/rest/services/ydtraffic/MapServer");
								// 实时
								trafficPic = new ArcGISDynamicMapServiceLayer(
										ditu
												+ "/arcgis/rest/services/ybhtraffic/MapServer");
								message = new Message();
								message.what = 2;

								handler.sendMessage(message);*/
							} else {

								Message message = new Message();
								message.what = 3;
								handler.sendMessage(message);
							}
						}else{
							
							Message message = new Message();
							message.what = 4;
							handler.sendMessage(message);
							
						}
			}
		}.start();

	}
	
	private Handler handler = new Handler() {
		@Override
		// 当有消息发送出来的时候就执行Handler的这个方法
		public void handleMessage(Message msg) {
			super.handleMessage(msg);
			// 处理UI
			switch (msg.what) {
			case 0:
				handler.post(mapimageUI5);
				break;
			case 1:
				handler.post(showRoadStringUI);
				break;
			case 2:
				handler.post(mapGisUI);
				break;

			case 3:
				CannotConnectServ();
				break;

			case 4:
				CannotConnectNet();
				break;
				
			case 5:
				handler.post(mapimageUI3);
				break;

			}

		}
	};

	@Override
	protected void onPause() {
		super.onPause();
		if (builder1 != null) {

			builder1.show().dismiss();
		}
		if (builder2 != null) {

			builder2.show().dismiss();
		}

	}
	
	protected void onStop(){
		super.onStop();
		if (builder1 != null) {

			builder1.show().dismiss();
		}
		if (builder2 != null) {

			builder2.show().dismiss();
		}
		
	}
	@Override
	protected void onDestroy() {
		super.onDestroy();

		timer.cancel();
		timer1.cancel();
		timer2.cancel();
		//handler.removeCallbacks(mapGisUI);
		finish();

	}

	AlertDialog.Builder builder2;

	public void CannotConnectNet() {// 当服务器连接不上的时候 就提示用户 并关闭主程序。

		builder2 = new AlertDialog.Builder(TrafficPicActivity.this);
		builder2.setTitle("错误");
		builder2.setMessage("无法连接互联网，请稍候重试");
		builder2.setCancelable(false); // 禁止取消键
		builder2.setNegativeButton("确认", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int which) {
				finish();
			}
		});
		builder2.create().show();

	}

	AlertDialog.Builder builder1;

	public void CannotConnectServ() {

		builder1 = new AlertDialog.Builder(TrafficPicActivity.this);
		builder1.setTitle("错误");
		builder1.setMessage("无法连接服务器，请稍候重试");
		builder1.setCancelable(false); // 禁止取消键
		builder1.setNegativeButton("确认", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int which) {
				
			}
		});
		builder1.create().show();
	}

	public boolean isConnByHttp() {
		boolean isConn = false;
		URL url;
		HttpURLConnection conn = null;

		try {
			// 外网
			// url = new URL("http://114.251.193.190:8899/phone");
			// 内网
			 //url = new URL("http://172.18.18.203");
			 url = new URL("http://172.28.18.2:7777/phone");

			conn = (HttpURLConnection) url.openConnection();

			// conn.setHeader("Range","bytes="+"");
			conn.setConnectTimeout(1000 * 8);
			if (conn.getResponseCode() == 200) {
				isConn = true;
			}

		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block

		} catch (IOException e) {
			// TODO Auto-generated catch block

		} finally {
			conn.disconnect();
		}
		return isConn;
	}

	Runnable mapGisUI=new Runnable(){
		
		public void run(){
			
			if (mapThread == false) {
				
				getMapImage();
				mapThread = true;
			} else {
			
				trafficPic.refresh();
				
			}
			
		}
		
	};
	
	Runnable mapimageUI5 = new Runnable() {
		@Override
		public void run() {
			getStaticMapImage5();
			
			

		}

	};
	
	Runnable mapimageUI3 = new Runnable() {
		@Override
		public void run() {
			getStaticMapImage3();
			
		}

	};

	private void getStaticMapImage5() {// 生成GIS地图图片
		//System.out.println("------------静态路况图5------------");

		 ImageView imageView = (ImageView) findViewById(R.id.MapPic);
		  
		 try {
		  
		 // 二进制数据生成位图 
		  Bitmap bit = BitmapFactory.decodeByteArray(data, 0,data.length);
		 
		 imageView.setImageBitmap(bit);
		 
		 } catch (Exception e) { 
			 Log.e("NetActivity", e.toString());
		 
		  Toast.makeText(TrafficPicActivity.this, "网络不通，无法显示路况图！", 1).show(); }
	}
	
	private void getStaticMapImage3() {// 生成GIS地图图片
		//System.out.println("------------静态路况图4------------");

		 ImageView imageView = (ImageView) findViewById(R.id.MapPic2);
		  
		 try {
		  
		 // 二进制数据生成位图 
		  Bitmap bit = BitmapFactory.decodeByteArray(data2, 0,data2.length);
		 
		 imageView.setImageBitmap(bit);
		 
		 } catch (Exception e) { 
			 Log.e("NetActivity", e.toString());
		 
		  Toast.makeText(TrafficPicActivity.this, "网络不通，无法显示路况图！", 1).show(); }
	}
	
	MapView mMapView = null;
	ArcGISTiledMapServiceLayer tileLayers;
	ArcGISDynamicMapServiceLayer trafficPic;// 路况图的图层

	private void getMapImage() {// 生成GIS地图图片
		//System.out.println("------------路况图------------");
		//System.out.println("getImage");
		mMapView = (MapView) findViewById(R.id.map);
		mMapView.addLayer(tileLayers);
		mMapView.addLayer(trafficPic);
		/*
		 * com.esri.core.geometry.Point pp = new com.esri.core.geometry.Point();
		 * pp.setXY(503428.999, 304586.842); mMapView.centerAt(pp, true);
		 */
		mMapView.setOnStatusChangedListener(new OnStatusChangedListener() {

			@Override
			public void onStatusChanged(Object source, STATUS status) {
				// TODO Auto-generated method stub
				if (status.equals(STATUS.INITIALIZED)) {

					com.esri.core.geometry.Point pp = new com.esri.core.geometry.Point();
					pp.setXY(503428.999, 304586.842);
					mMapView.zoomToScale(pp, 296666.16802390246);

				}

				if (status.equals(STATUS.LAYER_LOADED)) {
				//	mMapView.addLayer(trafficPic);
				}

			}

		});
	}

	public void Gislocation(View view) {// 恢复GIS初始位置
		
		ImageView dtImageView=(ImageView) findViewById(R.id.dt);
		ImageView rdimageView = (ImageView) findViewById(R.id.MapPic);
		 
		if(dtImageView.getVisibility()==0){
			rdimageView.setVisibility(View.INVISIBLE);
			dtImageView.setVisibility(View.INVISIBLE);
		}else{
			rdimageView.setVisibility(View.VISIBLE);
			dtImageView.setVisibility(View.VISIBLE);
			
		}
		
		/*com.esri.core.geometry.Point pp = new com.esri.core.geometry.Point();
		pp.setXY(503428.999, 304586.842);
		mMapView.zoomToScale(pp, 296666.16802390246);*/

	}

	private void AlertMsg(String str, Object... arg) {
		String msg = String.format(str, arg);
		Toast.makeText(this, msg, 2).show();
		Log.i("AlertMsg", msg);
	}

	public void MapPlus(View view) {
		//mMapView.zoomin();
		ImageView dt5ImageView=(ImageView) findViewById(R.id.dt);
		ImageView rd5imageView = (ImageView) findViewById(R.id.MapPic);
		ImageView dt4ImageView=(ImageView) findViewById(R.id.dt2);
		ImageView rd4imageView = (ImageView) findViewById(R.id.MapPic2);
		
		if(dt5ImageView.getVisibility()==0){
			rd5imageView.setVisibility(View.INVISIBLE);
			dt5ImageView.setVisibility(View.INVISIBLE);
			dt4ImageView.setVisibility(View.VISIBLE);
			rd4imageView.setVisibility(View.VISIBLE);
		}
	}

	public void MapMinus(View view) {
		//mMapView.zoomout();
		ImageView dt5ImageView=(ImageView) findViewById(R.id.dt);
		ImageView rd5imageView = (ImageView) findViewById(R.id.MapPic);
		ImageView dt4ImageView=(ImageView) findViewById(R.id.dt2);
		ImageView rd4imageView = (ImageView) findViewById(R.id.MapPic2);
		if(dt4ImageView.getVisibility()==0){
			rd5imageView.setVisibility(View.VISIBLE);
			dt5ImageView.setVisibility(View.VISIBLE);
			dt4ImageView.setVisibility(View.INVISIBLE);
			rd4imageView.setVisibility(View.INVISIBLE);
		}
	}

	String RoadString;

	/*public void ShowInfo(View view) {

		AlertMsg("显示信息");
		new Thread() {

			public void run() {
				RoadString = RoadNetWebService
						.getRoadNetString("getTrafficIndex");
				System.out.println(RoadString);
				Message message = new Message();
				message.what = 1;
				handler.sendMessage(message);

			}

		}.start();
	}
*/
	public void showRainBow(View view) {

		startActivity(new Intent(TrafficPicActivity.this, RainBowActivity.class));
	}
	Runnable showRoadStringUI = new Runnable() {

		@Override
		public void run() {
			//System.out.println(RoadString);
			showTrafficLineText();
			
			/*String[] SingleRoadValue = RoadString.split(";");
			String tableHtml = "";
			for (int i = 0; i < SingleRoadValue.length; i++) {
				String[] cloumnValue = SingleRoadValue[i].split(",");
				if (cloumnValue[4].toString().equals("green")) {
					tableHtml += "<font color='#00ff00'><b>" + cloumnValue[0]
							+ "&nbsp;&nbsp;&nbsp;" + cloumnValue[1]
							+ "&nbsp;&nbsp;&nbsp;" + cloumnValue[2]
							+ "&nbsp;&nbsp;&nbsp;" + cloumnValue[3]
							+ "</b></font><br>";
				} else if (cloumnValue[4].toString().equals("dgreen")) {
					tableHtml += "<font color='#32CD32'><b>" + cloumnValue[0]
							+ "&nbsp;&nbsp;&nbsp;" + cloumnValue[1]
							+ "&nbsp;&nbsp;&nbsp;" + cloumnValue[2]
							+ "&nbsp;&nbsp;&nbsp;" + cloumnValue[3]
							+ "</b></font><br>";
				} else if (cloumnValue[4].toString().equals("red")) {
					tableHtml += "<font color='#FF3030'><b>" + cloumnValue[0]
							+ "&nbsp;&nbsp;&nbsp;" + cloumnValue[1]
							+ "&nbsp;&nbsp;&nbsp;" + cloumnValue[2]
							+ "&nbsp;&nbsp;&nbsp;" + cloumnValue[3]
							+ "</b></font><br>";
				} else if (cloumnValue[4].toString().equals("yellow")) {
					tableHtml += "<font color='#EEEE00'><b>" + cloumnValue[0]
							+ "&nbsp;&nbsp;&nbsp;" + cloumnValue[1]
							+ "&nbsp;&nbsp;&nbsp;" + cloumnValue[2]
							+ "&nbsp;&nbsp;&nbsp;" + cloumnValue[3]
							+ "</b></font><br>";
				} else if (cloumnValue[4].toString().equals("orange")) {
					tableHtml += "<font color='#FFA500'><b>" + cloumnValue[0]
							+ "&nbsp;&nbsp;&nbsp;" + cloumnValue[1]
							+ "&nbsp;&nbsp;&nbsp;" + cloumnValue[2]
							+ "&nbsp;&nbsp;&nbsp;" + cloumnValue[3]
							+ "</b></font><br>";
				}
			}
			new AlertDialog.Builder(TrafficPicActivity.this)
					// 以对话框形式通知用户选择的列表内容
					.setTitle("路网信息").setMessage(Html.fromHtml(tableHtml))
					.setNegativeButton("关闭", null).show();*/
		}
	};
	
	public void showTrafficLineText(){
		
		String[] SingleRoadValue = RoadString.split(";");
		/* allnetTR=(TableRow) findViewById(R.id.allnetTR);
		 eastcityTr=(TableRow) findViewById(R.id.eastcityTr);
		 westcityTr=(TableRow) findViewById(R.id.westcityTr);
		 haidiancityTr=(TableRow) findViewById(R.id.haidiancityTr);
		 chaoyangcityTr=(TableRow) findViewById(R.id.chaoyangcityTr);
		 fengtaicityTr=(TableRow) findViewById(R.id.fengtaicityTr);
		 shijingshancityTr=(TableRow) findViewById(R.id.shijingshancityTr);
		 circle2Tr=(TableRow) findViewById(R.id.circle2Tr);
		 circle23Tr=(TableRow) findViewById(R.id.circle23Tr);
		 circle34Tr=(TableRow) findViewById(R.id.circle34Tr);
		 circle45Tr=(TableRow) findViewById(R.id.circle45Tr);*/
		for (int i = 0; i < SingleRoadValue.length; i++) {
			String[] cloumnValue = SingleRoadValue[i].split(",");
			if (cloumnValue[3].toString().equals("green")) {
				if(cloumnValue[0].equals("全路网")){
					
					allnetdata.setText(cloumnValue[1]);
					allnetstatus.setText(cloumnValue[2]);
					
					allnetdata.setTextColor(Color.parseColor("#00CD00"));
					allnetstatus.setTextColor(Color.parseColor("#00CD00"));
					allnet.setTextColor(Color.parseColor("#00CD00"));
					
				}else if(cloumnValue[0].equals("二环内")){
					
					circle2_data.setText(cloumnValue[1]);
					circle2_status.setText(cloumnValue[2]);
					circle2_data.setTextColor(Color.parseColor("#00CD00"));
					circle2_status.setTextColor(Color.parseColor("#00CD00"));
					circle2.setTextColor(Color.parseColor("#00CD00"));
				}else if(cloumnValue[0].equals("二环至三环")){
					circle23_data.setText(cloumnValue[1]);
					circle23_status.setText(cloumnValue[2]);
					circle23_data.setTextColor(Color.parseColor("#00CD00"));
					circle23_status.setTextColor(Color.parseColor("#00CD00"));
					circle23.setTextColor(Color.parseColor("#00CD00"));
				}else if(cloumnValue[0].equals("三环至四环")){
					circle34_data.setText(cloumnValue[1]);
					circle34_status.setText(cloumnValue[2]);
					circle34_data.setTextColor(Color.parseColor("#00CD00"));
					circle34_status.setTextColor(Color.parseColor("#00CD00"));
					circle34.setTextColor(Color.parseColor("#00CD00"));
				}else if(cloumnValue[0].equals("四环至五环")){
					circle45_data.setText(cloumnValue[1]);
					circle45_status.setText(cloumnValue[2]);
					circle45_data.setTextColor(Color.parseColor("#00CD00"));
					circle45_status.setTextColor(Color.parseColor("#00CD00"));
					circle45.setTextColor(Color.parseColor("#00CD00"));
				}else if(cloumnValue[0].equals("东城区")){
					
					eastcitydata.setText(cloumnValue[1]);
					eastcitystatus.setText(cloumnValue[2]);
					
					eastcitydata.setTextColor(Color.parseColor("#00CD00"));
					eastcitystatus.setTextColor(Color.parseColor("#00CD00"));
					eastcity.setTextColor(Color.parseColor("#00CD00"));
				}else if(cloumnValue[0].equals("西城区")){
					westcitydata.setText(cloumnValue[1]);
					westcitystatus.setText(cloumnValue[2]);
					westcitydata.setTextColor(Color.parseColor("#00CD00"));
					westcitystatus.setTextColor(Color.parseColor("#00CD00"));
					westcity.setTextColor(Color.parseColor("#00CD00"));
				}else if(cloumnValue[0].equals("海淀区")){
					haidiancity_data.setText(cloumnValue[1]);
					haidiancity_status.setText(cloumnValue[2]);
					haidiancity_data.setTextColor(Color.parseColor("#00CD00"));
					haidiancity_status.setTextColor(Color.parseColor("#00CD00"));
					haidiancity.setTextColor(Color.parseColor("#00CD00"));
				}else if(cloumnValue[0].equals("朝阳区")){
					chaoyangcity_data.setText(cloumnValue[1]);
					chaoyangcity_status.setText(cloumnValue[2]);
					chaoyangcity_data.setTextColor(Color.parseColor("#00CD00"));
					chaoyangcity_status.setTextColor(Color.parseColor("#00CD00"));
					chaoyangcity.setTextColor(Color.parseColor("#00CD00"));
				}else if(cloumnValue[0].equals("丰台区")){
					
					fengtaicity_data.setText(cloumnValue[1]);
					fengtaicity_status.setText(cloumnValue[2]);
					fengtaicity_data.setTextColor(Color.parseColor("#00CD00"));
					fengtaicity_status.setTextColor(Color.parseColor("#00CD00"));
					fengtaicity.setTextColor(Color.parseColor("#00CD00"));
				}else if(cloumnValue[0].equals("石景山区")){
					
					shijingshancity_data.setText(cloumnValue[1]);
					shijingshancity_status.setText(cloumnValue[2]);
					shijingshancity_data.setTextColor(Color.parseColor("#00CD00"));
					shijingshancity_status.setTextColor(Color.parseColor("#00CD00"));
					shijingshancity.setTextColor(Color.parseColor("#00CD00"));
				}
				
			}else if (cloumnValue[3].toString().equals("dgreen")) {
				if(cloumnValue[0].equals("全路网")){
					
					allnetdata.setText(cloumnValue[1]);
					allnetstatus.setText(cloumnValue[2]);
					
					allnetdata.setTextColor(Color.parseColor("#008B00"));
					allnetstatus.setTextColor(Color.parseColor("#008B00"));
					allnet.setTextColor(Color.parseColor("#008B00"));
					
				}else if(cloumnValue[0].equals("二环内")){
					
					circle2_data.setText(cloumnValue[1]);
					circle2_status.setText(cloumnValue[2]);
					circle2_data.setTextColor(Color.parseColor("#008B00"));
					circle2_status.setTextColor(Color.parseColor("#008B00"));
					circle2.setTextColor(Color.parseColor("#008B00"));
				}else if(cloumnValue[0].equals("二环至三环")){
					circle23_data.setText(cloumnValue[1]);
					circle23_status.setText(cloumnValue[2]);
					circle23_data.setTextColor(Color.parseColor("#008B00"));
					circle23_status.setTextColor(Color.parseColor("#008B00"));
					circle23.setTextColor(Color.parseColor("#008B00"));
				}else if(cloumnValue[0].equals("三环至四环")){
					circle34_data.setText(cloumnValue[1]);
					circle34_status.setText(cloumnValue[2]);
					circle34_data.setTextColor(Color.parseColor("#008B00"));
					circle34_status.setTextColor(Color.parseColor("#008B00"));
					circle34.setTextColor(Color.parseColor("#008B00"));
				}else if(cloumnValue[0].equals("四环至五环")){
					circle45_data.setText(cloumnValue[1]);
					circle45_status.setText(cloumnValue[2]);
					circle45_data.setTextColor(Color.parseColor("#008B00"));
					circle45_status.setTextColor(Color.parseColor("#008B00"));
					circle45.setTextColor(Color.parseColor("#008B00"));
				}else if(cloumnValue[0].equals("东城区")){
					
					eastcitydata.setText(cloumnValue[1]);
					eastcitystatus.setText(cloumnValue[2]);
					
					eastcitydata.setTextColor(Color.parseColor("#008B00"));
					eastcitystatus.setTextColor(Color.parseColor("#008B00"));
					eastcity.setTextColor(Color.parseColor("#008B00"));
				}else if(cloumnValue[0].equals("西城区")){
					westcitydata.setText(cloumnValue[1]);
					westcitystatus.setText(cloumnValue[2]);
					westcitydata.setTextColor(Color.parseColor("#008B00"));
					westcitystatus.setTextColor(Color.parseColor("#008B00"));
					westcity.setTextColor(Color.parseColor("#008B00"));
				}else if(cloumnValue[0].equals("海淀区")){
					haidiancity_data.setText(cloumnValue[1]);
					haidiancity_status.setText(cloumnValue[2]);
					haidiancity_data.setTextColor(Color.parseColor("#008B00"));
					haidiancity_status.setTextColor(Color.parseColor("#008B00"));
					haidiancity.setTextColor(Color.parseColor("#008B00"));
				}else if(cloumnValue[0].equals("朝阳区")){
					chaoyangcity_data.setText(cloumnValue[1]);
					chaoyangcity_status.setText(cloumnValue[2]);
					chaoyangcity_data.setTextColor(Color.parseColor("#008B00"));
					chaoyangcity_status.setTextColor(Color.parseColor("#008B00"));
					chaoyangcity.setTextColor(Color.parseColor("#008B00"));
				}else if(cloumnValue[0].equals("丰台区")){
					
					fengtaicity_data.setText(cloumnValue[1]);
					fengtaicity_status.setText(cloumnValue[2]);
					fengtaicity_data.setTextColor(Color.parseColor("#008B00"));
					fengtaicity_status.setTextColor(Color.parseColor("#008B00"));
					fengtaicity.setTextColor(Color.parseColor("#008B00"));
				}else if(cloumnValue[0].equals("石景山区")){
					
					shijingshancity_data.setText(cloumnValue[1]);
					shijingshancity_status.setText(cloumnValue[2]);
					shijingshancity_data.setTextColor(Color.parseColor("#008B00"));
					shijingshancity_status.setTextColor(Color.parseColor("#008B00"));
					shijingshancity.setTextColor(Color.parseColor("#008B00"));
				}
				
			}else if (cloumnValue[3].toString().equals("red")) {
				
				if(cloumnValue[0].equals("全路网")){
					
					allnetdata.setText(cloumnValue[1]);
					allnetstatus.setText(cloumnValue[2]);
					
					allnetdata.setTextColor(Color.parseColor("#FF0000"));
					allnetstatus.setTextColor(Color.parseColor("#FF0000"));
					allnet.setTextColor(Color.parseColor("#FF0000"));
					
				}else if(cloumnValue[0].equals("二环内")){
					
					circle2_data.setText(cloumnValue[1]);
					circle2_status.setText(cloumnValue[2]);
					circle2_data.setTextColor(Color.parseColor("#FF0000"));
					circle2_status.setTextColor(Color.parseColor("#FF0000"));
					circle2.setTextColor(Color.parseColor("#FF0000"));
				}else if(cloumnValue[0].equals("二环至三环")){
					circle23_data.setText(cloumnValue[1]);
					circle23_status.setText(cloumnValue[2]);
					circle23_data.setTextColor(Color.parseColor("#FF0000"));
					circle23_status.setTextColor(Color.parseColor("#FF0000"));
					circle23.setTextColor(Color.parseColor("#FF0000"));
				}else if(cloumnValue[0].equals("三环至四环")){
					circle34_data.setText(cloumnValue[1]);
					circle34_status.setText(cloumnValue[2]);
					circle34_data.setTextColor(Color.parseColor("#FF0000"));
					circle34_status.setTextColor(Color.parseColor("#FF0000"));
					circle34.setTextColor(Color.parseColor("#FF0000"));
				}else if(cloumnValue[0].equals("四环至五环")){
					circle45_data.setText(cloumnValue[1]);
					circle45_status.setText(cloumnValue[2]);
					circle45_data.setTextColor(Color.parseColor("#FF0000"));
					circle45_status.setTextColor(Color.parseColor("#FF0000"));
					circle45.setTextColor(Color.parseColor("#FF0000"));
				}else if(cloumnValue[0].equals("东城区")){
					
					eastcitydata.setText(cloumnValue[1]);
					eastcitystatus.setText(cloumnValue[2]);
					
					eastcitydata.setTextColor(Color.parseColor("#FF0000"));
					eastcitystatus.setTextColor(Color.parseColor("#FF0000"));
					eastcity.setTextColor(Color.parseColor("#FF0000"));
				}else if(cloumnValue[0].equals("西城区")){
					westcitydata.setText(cloumnValue[1]);
					westcitystatus.setText(cloumnValue[2]);
					westcitydata.setTextColor(Color.parseColor("#FF0000"));
					westcitystatus.setTextColor(Color.parseColor("#FF0000"));
					westcity.setTextColor(Color.parseColor("#FF0000"));
				}else if(cloumnValue[0].equals("海淀区")){
					haidiancity_data.setText(cloumnValue[1]);
					haidiancity_status.setText(cloumnValue[2]);
					haidiancity_data.setTextColor(Color.parseColor("#FF0000"));
					haidiancity_status.setTextColor(Color.parseColor("#FF0000"));
					haidiancity.setTextColor(Color.parseColor("#FF0000"));
				}else if(cloumnValue[0].equals("朝阳区")){
					chaoyangcity_data.setText(cloumnValue[1]);
					chaoyangcity_status.setText(cloumnValue[2]);
					chaoyangcity_data.setTextColor(Color.parseColor("#FF0000"));
					chaoyangcity_status.setTextColor(Color.parseColor("#FF0000"));
					chaoyangcity.setTextColor(Color.parseColor("#FF0000"));
				}else if(cloumnValue[0].equals("丰台区")){
					
					fengtaicity_data.setText(cloumnValue[1]);
					fengtaicity_status.setText(cloumnValue[2]);
					fengtaicity_data.setTextColor(Color.parseColor("#FF0000"));
					fengtaicity_status.setTextColor(Color.parseColor("#FF0000"));
					fengtaicity.setTextColor(Color.parseColor("#FF0000"));
				}else if(cloumnValue[0].equals("石景山区")){
					
					shijingshancity_data.setText(cloumnValue[1]);
					shijingshancity_status.setText(cloumnValue[2]);
					shijingshancity_data.setTextColor(Color.parseColor("#FF0000"));
					shijingshancity_status.setTextColor(Color.parseColor("#FF0000"));
					shijingshancity.setTextColor(Color.parseColor("#FF0000"));
				}
			}else if (cloumnValue[3].toString().equals("yellow")) {
				
				if(cloumnValue[0].equals("全路网")){
					
					allnetdata.setText(cloumnValue[1]);
					allnetstatus.setText(cloumnValue[2]);
					
					allnetdata.setTextColor(Color.parseColor("#FFFF00"));
					allnetstatus.setTextColor(Color.parseColor("#FFFF00"));
					allnet.setTextColor(Color.parseColor("#FFFF00"));
					
				}else if(cloumnValue[0].equals("二环内")){
					
					circle2_data.setText(cloumnValue[1]);
					circle2_status.setText(cloumnValue[2]);
					circle2_data.setTextColor(Color.parseColor("#FFFF00"));
					circle2_status.setTextColor(Color.parseColor("#FFFF00"));
					circle2.setTextColor(Color.parseColor("#FFFF00"));
				}else if(cloumnValue[0].equals("二环至三环")){
					circle23_data.setText(cloumnValue[1]);
					circle23_status.setText(cloumnValue[2]);
					circle23_data.setTextColor(Color.parseColor("#FFFF00"));
					circle23_status.setTextColor(Color.parseColor("#FFFF00"));
					circle23.setTextColor(Color.parseColor("#FFFF00"));
				}else if(cloumnValue[0].equals("三环至四环")){
					circle34_data.setText(cloumnValue[1]);
					circle34_status.setText(cloumnValue[2]);
					circle34_data.setTextColor(Color.parseColor("#FFFF00"));
					circle34_status.setTextColor(Color.parseColor("#FFFF00"));
					circle34.setTextColor(Color.parseColor("#FFFF00"));
				}else if(cloumnValue[0].equals("四环至五环")){
					circle45_data.setText(cloumnValue[1]);
					circle45_status.setText(cloumnValue[2]);
					circle45_data.setTextColor(Color.parseColor("#FFFF00"));
					circle45_status.setTextColor(Color.parseColor("#FFFF00"));
					circle45.setTextColor(Color.parseColor("#FFFF00"));
				}else if(cloumnValue[0].equals("东城区")){
					
					eastcitydata.setText(cloumnValue[1]);
					eastcitystatus.setText(cloumnValue[2]);
					
					eastcitydata.setTextColor(Color.parseColor("#FFFF00"));
					eastcitystatus.setTextColor(Color.parseColor("#FFFF00"));
					eastcity.setTextColor(Color.parseColor("#FFFF00"));
				}else if(cloumnValue[0].equals("西城区")){
					westcitydata.setText(cloumnValue[1]);
					westcitystatus.setText(cloumnValue[2]);
					westcitydata.setTextColor(Color.parseColor("#FFFF00"));
					westcitystatus.setTextColor(Color.parseColor("#FFFF00"));
					westcity.setTextColor(Color.parseColor("#FFFF00"));
				}else if(cloumnValue[0].equals("海淀区")){
					haidiancity_data.setText(cloumnValue[1]);
					haidiancity_status.setText(cloumnValue[2]);
					haidiancity_data.setTextColor(Color.parseColor("#FFFF00"));
					haidiancity_status.setTextColor(Color.parseColor("#FFFF00"));
					haidiancity.setTextColor(Color.parseColor("#FFFF00"));
				}else if(cloumnValue[0].equals("朝阳区")){
					chaoyangcity_data.setText(cloumnValue[1]);
					chaoyangcity_status.setText(cloumnValue[2]);
					chaoyangcity_data.setTextColor(Color.parseColor("#FFFF00"));
					chaoyangcity_status.setTextColor(Color.parseColor("#FFFF00"));
					chaoyangcity.setTextColor(Color.parseColor("#FFFF00"));
				}else if(cloumnValue[0].equals("丰台区")){
					
					fengtaicity_data.setText(cloumnValue[1]);
					fengtaicity_status.setText(cloumnValue[2]);
					fengtaicity_data.setTextColor(Color.parseColor("#FFFF00"));
					fengtaicity_status.setTextColor(Color.parseColor("#FFFF00"));
					fengtaicity.setTextColor(Color.parseColor("#FFFF00"));
				}else if(cloumnValue[0].equals("石景山区")){
					
					shijingshancity_data.setText(cloumnValue[1]);
					shijingshancity_status.setText(cloumnValue[2]);
					shijingshancity_data.setTextColor(Color.parseColor("#FFFF00"));
					shijingshancity_status.setTextColor(Color.parseColor("#FFFF00"));
					shijingshancity.setTextColor(Color.parseColor("#FFFF00"));
				}
			}else if (cloumnValue[3].toString().equals("orange")) {
				
				if(cloumnValue[0].equals("全路网")){
					
					allnetdata.setText(cloumnValue[1]);
					allnetstatus.setText(cloumnValue[2]);
					
					allnetdata.setTextColor(Color.parseColor("#FF7F24"));
					allnetstatus.setTextColor(Color.parseColor("#FF7F24"));
					allnet.setTextColor(Color.parseColor("#FF7F24"));
					
				}else if(cloumnValue[0].equals("二环内")){
					
					circle2_data.setText(cloumnValue[1]);
					circle2_status.setText(cloumnValue[2]);
					circle2_data.setTextColor(Color.parseColor("#FF7F24"));
					circle2_status.setTextColor(Color.parseColor("#FF7F24"));
					circle2.setTextColor(Color.parseColor("#FF7F24"));
				}else if(cloumnValue[0].equals("二环至三环")){
					circle23_data.setText(cloumnValue[1]);
					circle23_status.setText(cloumnValue[2]);
					circle23_data.setTextColor(Color.parseColor("#FF7F24"));
					circle23_status.setTextColor(Color.parseColor("#FF7F24"));
					circle23.setTextColor(Color.parseColor("#FF7F24"));
				}else if(cloumnValue[0].equals("三环至四环")){
					circle34_data.setText(cloumnValue[1]);
					circle34_status.setText(cloumnValue[2]);
					circle34_data.setTextColor(Color.parseColor("#FF7F24"));
					circle34_status.setTextColor(Color.parseColor("#FF7F24"));
					circle34.setTextColor(Color.parseColor("#FF7F24"));
				}else if(cloumnValue[0].equals("四环至五环")){
					circle45_data.setText(cloumnValue[1]);
					circle45_status.setText(cloumnValue[2]);
					circle45_data.setTextColor(Color.parseColor("#FF7F24"));
					circle45_status.setTextColor(Color.parseColor("#FF7F24"));
					circle45.setTextColor(Color.parseColor("#FF7F24"));
				}else if(cloumnValue[0].equals("东城区")){
					
					eastcitydata.setText(cloumnValue[1]);
					eastcitystatus.setText(cloumnValue[2]);
					
					eastcitydata.setTextColor(Color.parseColor("#FF7F24"));
					eastcitystatus.setTextColor(Color.parseColor("#FF7F24"));
					eastcity.setTextColor(Color.parseColor("#FF7F24"));
				}else if(cloumnValue[0].equals("西城区")){
					westcitydata.setText(cloumnValue[1]);
					westcitystatus.setText(cloumnValue[2]);
					westcitydata.setTextColor(Color.parseColor("#FF7F24"));
					westcitystatus.setTextColor(Color.parseColor("#FF7F24"));
					westcity.setTextColor(Color.parseColor("#FF7F24"));
				}else if(cloumnValue[0].equals("海淀区")){
					haidiancity_data.setText(cloumnValue[1]);
					haidiancity_status.setText(cloumnValue[2]);
					haidiancity_data.setTextColor(Color.parseColor("#FF7F24"));
					haidiancity_status.setTextColor(Color.parseColor("#FF7F24"));
					haidiancity.setTextColor(Color.parseColor("#FF7F24"));
				}else if(cloumnValue[0].equals("朝阳区")){
					chaoyangcity_data.setText(cloumnValue[1]);
					chaoyangcity_status.setText(cloumnValue[2]);
					chaoyangcity_data.setTextColor(Color.parseColor("#FF7F24"));
					chaoyangcity_status.setTextColor(Color.parseColor("#FF7F24"));
					chaoyangcity.setTextColor(Color.parseColor("#FF7F24"));
				}else if(cloumnValue[0].equals("丰台区")){
					
					fengtaicity_data.setText(cloumnValue[1]);
					fengtaicity_status.setText(cloumnValue[2]);
					fengtaicity_data.setTextColor(Color.parseColor("#FF7F24"));
					fengtaicity_status.setTextColor(Color.parseColor("#FF7F24"));
					fengtaicity.setTextColor(Color.parseColor("#FF7F24"));
				}else if(cloumnValue[0].equals("石景山区")){
					
					shijingshancity_data.setText(cloumnValue[1]);
					shijingshancity_status.setText(cloumnValue[2]);
					shijingshancity_data.setTextColor(Color.parseColor("#FF7F24"));
					shijingshancity_status.setTextColor(Color.parseColor("#FF7F24"));
					shijingshancity.setTextColor(Color.parseColor("#FF7F24"));
				}
			}
			
		}
		
	}
}
